﻿
import Request from '../../base/request.js?t=202511041006'
import Storage from '../../base/storage.js?t=202511041006'
import { imageBaseUrl, isImageFile, getBrowserInfo } from  "../../base/utils.js?t=202511041006"
const Composition = (proxy) => {
    const data = reactive({
        pdfOpen: false,
        pdfurl: "",
        cmainId: "",
        current: 0,
        messageTest: "",
        proxy: "",
        popOpen:false,
        s1Form: {
            TypeId: [],
            DepartmentId: [],
            WorkAddress: "",
            ProductAddress: "",
            Targetld: "",
            OtherTarget: "",
            AllTime: [],
            StartTime: "",
            EndTime: "",
            Range: "",
            GuideLine: [],
            OtherGuideLine: "",
            CaseManager: "",
            Remark: "",
            fileslist: ""
        },

        s1FormRule: {
            TypeId: { required: true, message: '请选择计划类型', trigger: 'change' },
            DepartmentId: { required: true, message: '请选择受审核部门', trigger: 'change' },
            WorkAddress: { required: true, message: '请填写办公地址', trigger: 'change' },
            ProductAddress: { required: true, message: '请填写生产地址', trigger: 'change' },
            Targetld: { required: true, message: '请选择审核目的', trigger: 'change' },
            AllTime: { type: 'array', required: true, message: '请选择审核日期', trigger: 'change' },
            GuideLine: { required: true, message: '请选择审核准则', trigger: 'change' },
            CaseManager: { required: true, message: '请选择方案管理人员', trigger: 'change' },

        },

        s3Form: {
            TeamId: "",
            StartTime: "",
            EndTime: "",
            DepartmentId: "",
            Factor: "",
        },
        s4Form: {
            Title: "",
            PublishTime: "",
            Content: "",
            dept:""
        },
        s4FormRule: {
            Title: { required: true, message: '请输入通知标题', trigger: 'change' },

            Content: { required: true, message: '请输入通知内容', trigger: 'change' },
        },
        groupList: [{
            TeamName: "",
            MemberList: [{
                prule: "",
                pname: "",
                ptel: "",
                pduty: "",
                MemberId:""
            }]
        }],

        dateList: [{
            AllTime:"",
            TeamId: "",
            StartTime: "",
            EndTime: "",
            DepartmentId: "",
            Factor: "",
            gmember:""
        }],
        isChooseAll:false,
        gp1: 0,
        gp2:0,
        sgroupList:[],


        previewShow: false,
        imgUrl:"",
        email: "",
        tel:"",

        planTypeList: [
  
        ],
     
        beCheckDeptList: [],
        aimList: [],
        rules: [
           
        ],
        deptList: [
           
        ],

        memberList:[],
       
        items: [
            {
                title: '填写内部审核计划信息',
            },
            {
                title: '设置审核组',
            },
            {
                title: '设置审核日程',
            },
            {
                title: '发布年度考核计划',
            },
        ].map(item => ({ key: item.title, title: item.title })),
        fileList: [

        ],
        itemRender: (data) => {

            let uid = data.file.uid
            const previewBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnPreview(uid) }, src: "../Bussiness/img/svg/preview.svg", width: 20, height: 22 }, { default: () => '预览'})
            const downloadBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnDownLoad(uid) }, src: "../Bussiness/img/svg/download.svg", width: 20, height: 22 }, { default: () => '下载' } )
            const deleteBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnDelete(uid) }, src: "../Bussiness/img/svg/delete.svg", width: 18, height: 22 }, { default: () => '删除' } )
            var btns = ""
            console.log(data.file,'data.file')
   
            if (isImageFile(data.file.url)) {
                btns = h('div', { style: "display:flex;margin-left:10px" }, {
                        default: () => [
                            previewBtn,
                            downloadBtn,
                            deleteBtn
                        ] }        )
            } else {
                btns = h('div', { style: "display:flex;margin-left:10px" }, {
                    default: () => [
                        downloadBtn,
                        deleteBtn
                    ]
                })
            }

            return h('div', { style: 'margin-top:10px; width:100%;align-items:center; display:flex;justify-content:space-between' }, {
                default: () => [
                    data.file.name, btns
                ]
            })
    
        },
    })
    let params = toRefs(data)


    const methods = {
        handleTableChange: (page) => {
            const { current, pageSize } = page
            params.pagination.value.current = current;
            params.pagination.value.pageSize = pageSize;
            console.log(current, pageSize )
        },
        chooseAll: () => {
            params.isChooseAll.value = !params.isChooseAll.value
            if (params.isChooseAll.value) {
                params.s1Form.value.DepartmentId = params.deptList.value.map(e => e.value)
            } else {
                params.s1Form.value.DepartmentId = []
            }
     


        },

        dateChange: (e) => {
            params.s1Form.value.StartTime = dayjs(e[0]).format('YYYY-MM-DD')
            params.s1Form.value.EndTime = dayjs(e[1]).format('YYYY-MM-DD')
        },

        dateChange1: (e) => {
            params.dateList.value[params.gp1.value].StartTime = dayjs(e[0]).format('YYYY-MM-DD HH:mm:ss')
            params.dateList.value[params.gp1.value].EndTime = dayjs(e[1]).format('YYYY-MM-DD HH:mm:ss')
        },
        getDict: () => {
            return new Promise((resolve, rej) => {
                let info = Storage.get('AccountInfo', true)
                Request({
                    url: "/Account/createJwtToken",
                    method: 'post',
                    data: {
                        "userName": info && info.UserNo
                    }
                }).then(res => {
                    Storage.set('token', res.Data,true)
                    Request({
                        url: "/SystemConfig/GetDepartmentList",
                        method: 'post',

                    }).then(res5 => {
                        params.deptList.value = res5.Data.map(e => {
                            return {
                                label: e.DepartmentName,
                                value: e.Id
                            }
                        })
                    });
                    Request({
                        url: "/performance/getperformanceconfig",
                        method: 'post',
                        params: {
                            TypeId: 1
                        }
                    }).then(res1 => {

                        params.planTypeList.value = res1 && res1.Data.map(e => {
                            return {
                                label: e.ConfigName,
                                value: e.Id
                            }
                        })
                    });

                    Request({
                        url: "/performance/getperformanceconfig",
                        method: 'post',
                        params: {
                            TypeId: 2
                        }
                    }).then(res2 => {

                        params.aimList.value = res2 && res2.Data.map(e => {
                            return {
                                label: e.ConfigName,
                                value: e.Id,
                                IsInput: e.IsInput
                            }
                        })


                    });


                    Request({
                        url: "/performance/getteammemberlist",
                        method: 'post',

                    }).then(res4 => {


                        params.memberList.value = res4.Data.map(e => {
                            return {
                                label: `${e.UserName}(${e.UserNo})`,
                                value: e.UserNo,
                                email: e.Email,
                                tel: e.Phone,
                                role: e.JobRole,
                                duty: e.JobTitle,
                                MemberId: e.Id

                            }
                        })

                        resolve(res4)

                    });


                    Request({
                        url: "/performance/getperformanceconfig",
                        method: 'post',
                        params: {
                            TypeId: 3
                        }
                    }).then(res3 => {

                        params.rules.value = res3 && res3.Data.map(e => {
                            return {
                                label: e.ConfigName,
                                value: e.Id,
                                IsInput: e.IsInput
                            }
                        })
 
                    });
                })
            })

          
        },
        memberChoose: (e) => {
  
            let item = params.memberList.value.find(es => es.value == e)

            const { tel, email } = item
            params.email.value = email;
            params.tel.value = tel;
        },
        test: (i, is) => {
            if (i) {
                params.gp1.value = i
            }
            if (is) {
                params.gp2.value = is
            }
      
         

        },
        gmemberChoose1: (e) => {

       

            let item = params.memberList.value.find(es => es.value == e)

            const { role, tel, duty, MemberId}=item
            params.groupList.value[params.gp1.value].MemberList[params.gp2.value].prule=role
            params.groupList.value[params.gp1.value].MemberList[params.gp2.value].ptel = tel
            params.groupList.value[params.gp1.value].MemberList[params.gp2.value].pduty = duty
            params.groupList.value[params.gp1.value].MemberList[params.gp2.value].MemberId = MemberId
                
        },
        gmemberChoose2: (e) => {
            let item = params.sgroupList.value.find(es => es.value == e)
            const { list } = item
            params.dateList.value[params.gp1.value].gmember = list.map(e => `${e.MemberName}(${e.UserNo})`).toString()
        },





        next: async() => {
            switch (params.current.value) {
                case 0:
                  methods.step1Add().then((res) => {
                        window.location.href = `/Performance/PerformancePlanAdd?id=${res.Data}&step=${1}`
                    })
                    break;
                case 1:
                 await methods.step2Add()
                    Request({
                        url: "/performance/getplanteamlist",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res => {
                        params.sgroupList.value = res.Data.map(e => {
                            return {
                                label: e.TeamName,
                                value: e.Id,
                                list: e.MemberList
                            }
                        })
                    })
                    Request({
                        url: "/performance/getplandepartments",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res1 => {
                     
                        params.beCheckDeptList.value = res1.Data.map(e => {
                            return {
                                label: e.DepartmentName,
                                value: e.Id,
                            }
                        })
                    })
                    window.location.href = `/Performance/PerformancePlanAdd?id=${params.cmainId.value}&step=${2}`
                 
                    break;
                case 2:
               await   methods.step3Add()
                    Request({
                        url: "/performance/getplandepartments",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res1 => {
                        params.s4Form.value.dept = res1.Data.map(e => e.DepartmentName).toString()
                    })
                    window.location.href = `/Performance/PerformancePlanAdd?id=${params.cmainId.value}&step=${3}`

                    break;
                case 3:
                    await methods.finish()
                    params.current.value=4
  
                    setTimeout(() => {
                        window.location.href = '/Performance/PerformancePlanPageList'
                    }, 1000)

                    break;
        

             }

            //params.current.value++;
        
        },
        prev: () => {
            params.current.value-=1
            window.location.href = `/Performance/PerformancePlanAdd?id=${params.cmainId.value}&step=${params.current.value}`
        },
        save: async() => {
            switch (params.current.value) {
                case 0:
    
                  await  methods.step1Add()
                    break;
                case 1:

                    await methods.step2Add()
                    break;


                case 2:

                    await  methods.step3Add()
                    break;


                case 3:

                    await  methods.step4Add()
                    await  methods.step4Add()
                    break;
            }
         
        },


        step1Add:  () => {
            return new Promise((resolve, rej) => {

                params.proxy.value.$refs.s1FormRule.validate().then(() => {
             
                        let subForm = JSON.parse(JSON.stringify(params.s1Form.value))
                        subForm.DepartmentId = subForm.DepartmentId.toString()
                    subForm.GuideLine = subForm.GuideLine.toString()
                       subForm.TypeId = subForm.TypeId.toString()
                        subForm.fileslist = params.fileList.value.map(e => e.FileId)
                    function queryURLParams() {
                        const searchParams = window.location.search.substring(1).split("&");
                        const params = {};

                        for (const param of searchParams) {
                            const [key, value] = param.split("=");
                            params[key] = value;
                        }

                        return params;
                    }
                    const { id } = queryURLParams()

                    if (id) {
                        Request({
                            url: "/performance/EditPlanBasic",
                            method: 'post',
                            data: { ...subForm, Id:id}
                        }).then(res => {
                            params.messageTest.value.success(res.Msg);
                            params.cmainId.value = res.Data

                            resolve(res)
                        })
                    } else {

                        Request({
                            url: "/performance/addplanbasic",
                            method: 'post',
                            data: subForm
                        }).then(res => {
                            params.messageTest.value.success(res.Msg);
                            params.cmainId.value = res.Data

                            resolve(res)
                        })

                    }

                  

                  

                }).catch(error => {
                    if (error.errorFields.length != 0) {
                        params.messageTest.value.warn(error.errorFields[0].errors[0])
                    }
            
            })
            });



     
        },
        //Status
        step2Add: () => {
            return new Promise((resolve, rej) => {
                let subForm = JSON.parse(JSON.stringify(params.groupList.value))
                subForm = subForm.map(e => {
                    return {
                        ...e,
                        FormId: params.cmainId.value
                    }
                })
                Request({
                    url: "/performance/AddPlanTeam",
                    method: 'post',
                    data: subForm
                }).then(res => {
        
                    params.messageTest.value.success(res.Msg);
                    resolve(res)
                  
                })
            })
            
        
        },
        step3Add: () => {
            return new Promise((resolve, rej) => {
                let subForm = JSON.parse(JSON.stringify(params.dateList.value))
                subForm = subForm.map(e => {
                    return {
                        ...e,
                        FormId: params.cmainId.value
                    }
                })

                Request({
                    url: "/performance/addplanschedule",
                    method: 'post',
                    data: subForm
                }).then(res => {
                    params.messageTest.value.success(res.Msg);
                    resolve(res)
                 
                })
            })
        },


        step4Add: () => {
            return new Promise((resolve, rej) => {
                let subForm = JSON.parse(JSON.stringify(params.s4Form.value))
                subForm.FormId = params.cmainId.value
                subForm.PublishTime = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')

                Request({
                    url: "/performance/addplannotice",
                    method: 'post',
                    data: subForm
                }).then(res => {
                    params.messageTest.value.success(res.Msg);
                    resolve(res)
                 

                })
            })
        },
        finish: () => {
            return new Promise((resolve, rej) => {

                params.proxy.value.$refs.s4FormRule.validate().then(() => {

                    methods.step4Add().then(res => {
                        let subForm = JSON.parse(JSON.stringify(params.s4Form.value))
                        subForm.FormId = params.cmainId.value
                        subForm.PublishTime = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')

                        Request({
                            url: "/performance/SubmitPlanForm",
                            method: 'post',
                            data: subForm
                        }).then(res => {
                            params.messageTest.value.success(res.Msg);
                            resolve(res)
                        })

                    })


              


                }).catch(error => {
                    if (error.errorFields.length != 0) {
                        params.messageTest.value.warn(error.errorFields[0].errors[0])
                    }

                })
            });




        },
       
        checkIsEmpty: (id) => {
            return new Promise((resolve, rej) => {
                Request({
                    url: "/performance/GetPlanDetail",
                    method: 'post',
                    params: {
                        FormId: id,
                        Step: +params.current.value + 1
                    }
                }).then(res => {
       
                    if (res.Data.length == 0) {
                        resolve(true)
                    } else {
                        resolve(false)
                    }


                })
            })
     
        
        },


        addGroup: () => {

                let obj = {
                    TeamName: "",
                    MemberList: [{
                        prule: "",
                        pname: "",
                        ptel: "",
                        pduty: "",
                        MemberId: ""
                    }]
                }

            params.groupList.value.unshift(obj)
        },
        delGroup: async (index, e) => {

            if (e && e.Id) {
                let res = await methods.checkIsEmpty(e.FormId)
                if (res) {
                    params.groupList.value.splice(index, 1)
                } else {
                    Request({
                        url: "/performance/DeletePlanTeam",
                        method: 'post',
                        params: {
                            Id: e.Id
                        }
                    }).then(res => {
                        params.messageTest.value.success(res.Msg);
                        params.groupList.value.splice(index, 1)
                    })

                }
            } else {
                params.groupList.value.splice(index, 1)
            }
      
 
        },

        addGroupInfo:  (i) => {
            let obj = {
                prule: "",
                pname: "",
                ptel: "",
                pemail: "",
                MemberId:""
            }

            params.groupList.value[i].MemberList.unshift(obj)
        },
        delGroupInfo: async (i, is,e,es) => {

        
            if (e && e.FormId && es && es.MemberId) {

                let res = await methods.checkIsEmpty(e.FormId)
                if (res) {
                    params.groupList.value.splice(index, 1)
                } else {
                    Request({
                        url: "/performance/DeletePlanTeamMember",
                        method: 'post',
                        params: {
                            MemberId: es.MemberId,
                            TeamId: e.Id
                        }
                    }).then(res => {
                        params.messageTest.value.success(res.Msg);
                        params.groupList.value[i].MemberList.splice(is, 1)
                    })

                }
            } else {
                params.groupList.value[i].MemberList.splice(is, 1)
            }


        },


        addDate: () => {
            let obj = {
                AllTime: "",
                TeamId: "",
                StartTime: "",
                EndTime: "",
                DepartmentId: "",
                Factor: "",
                gmember: ""
            }

            params.dateList.value.push(obj)
        },
        delDate: async(index, e) => {

            if (e && e.Id) {
                let res = await methods.checkIsEmpty(e.FormId)
                if (res) {
                    params.groupList.value.splice(index, 1)
                } else {
                    Request({
                        url: "/performance/DeletePlanSchedule",
                        method: 'post',
                        params: {
                            Id: e.Id
                        }
                    }).then(res => {
                        params.messageTest.value.success(res.Msg);
                        params.dateList.value.splice(index, 1)
                    })

                }
            } else {
                params.dateList.value.splice(index, 1)
            }

        },



        downloadfun: (name, url) => {
            fetch(url)
                .then(response => {
                    if (!response.ok) {
                        throw new Error('Network response was not ok');
                    }
                    return response.blob();
                })
                .then(blob => {
                    const link = document.createElement('a');
                    link.href = URL.createObjectURL(blob);
                    link.download = name;
                    link.target = "_blank"; // 可选，如果希望在新窗口中下载文件，请取消注释此行

                    // 兼容性处理：对于不支持 click() 方法的浏览器
                    if (document.createEvent) {
                        const event = document.createEvent('MouseEvents');
                        event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                        link.dispatchEvent(event);
                    } else {
                        link.click();
                    }

                    // 移除链接
                    document.body.removeChild(link);

                    // 释放 URL 对象
                    URL.revokeObjectURL(link.href);
                })
                .catch(error => {
                    console.error('There was a problem with the fetch operation:', error);
                });
        },
        setVisible : (value)=> {
            params.previewShow.value = value;
        },
        btnPreview: (e) => {
            let item = params.fileList.value.find(es => es.uid == e)
            item.url = item.FilePath || item.url
            if (item.url.indexOf('.pdf') != -1) {
                params.pdfurl.value = item.url
                params.pdfOpen.value = true


            } else {
                params.imgUrl.value = item.url
                methods.setVisible(true)
            }

 
        },
        btnDownLoad: (e) => {
            let item = params.fileList.value.find(es => es.uid == e)
            item.url = item.FilePath || item.url
            const { name, url } = item

            downloadfun(name, url)
            
},
        btnDelete: (e) => {
            params.fileList.value = params.fileList.value.filter(es => es.uid != e)
        },

        handleChange: (info) => {
            let formData = new FormData();
            formData.append('nfile',info.file.originFileObj)
            formData.append('uid', info.file.originFileObj.uid)
            Request({
                url: "/download/uploadfile?Path=Performance",
                method: 'post',
                data: formData
            }).then(res => {
                let item = params.fileList.value.find(e => e.uid == res.Data[0].uid)
                item.url = imageBaseUrl + res.Data[0].FilePath.split('../..')[1]
                item.FileId = res.Data[0].FileId
                item.FileName = res.Data[0].FileName
                item.name = res.Data[0].FileName
            })

        },
        handleDrop: (e) => {
            console.log(e,'drag');
        },

        filterOption: (val, type) => {
            return type.label.includes(val)
        },
        init: async () => {
              getBrowserInfo().catch(err => { console.log(err)})
            if (proxy) {
                params.proxy.value=proxy
            }
            const { message } = antd
            params.messageTest.value = message
            params.messageTest.value.config({
                top: `10vh`,
                duration: 7,
                maxCount: 1,
                rtl: true,
            });

            //初始化字典
       await  methods.getDict()


    //获取地址参数
            function queryURLParams() {
                const searchParams = window.location.search.substring(1).split("&");
                const params = {};

                for (const param of searchParams) {
                    const [key, value] = param.split("=");
                    params[key] = value;
                }

                return params;
            }
            const { id,step } = queryURLParams()
            if (id) {
                params.cmainId.value = id
                    params.current.value = +step
     


            }


            switch (params.current.value) {
                case 0:
                    if (id) {  
                      Request({
                        url: "/performance/getplandepartments",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res1 => {
                        params.s4Form.value.dept = res1.Data.map(e => e.DepartmentName).toString()

                        Request({
                            url: "/performance/GetPlanDetail",
                            method: 'post',
                            params: {
                                FormId: id,
                                Step: +step + 1
                            }
                        }).then(res => {
                            params.s1Form.value = res.Data

                            params.s1Form.value.DepartmentId= params.s1Form.value.DepartmentList
                            params.s1Form.value.TypeId = params.s1Form.value.TypeList
                            params.s1Form.value.GuideLine = params.s1Form.value.GuideLineList

                            params.s1Form.value.TargetId = +params.s1Form.value.TargetId
                            const regex = /\/Date\((\d+)\)\//;
                            const match1 = params.s1Form.value.StartTime.match(regex);
                            const match2 = params.s1Form.value.EndTime.match(regex);
                            if (match1 && match2) {
                                params.s1Form.value.StartTime = dayjs(parseInt(match1[1], 10)).format('YYYY-MM-DD')
                                params.s1Form.value.EndTime = dayjs(parseInt(match2[1], 10)).format('YYYY-MM-DD')
                                params.s1Form.value.AllTime = [dayjs(params.s1Form.value.StartTime, 'YYYY-MM-DD'), dayjs(params.s1Form.value.EndTime, 'YYYY-MM-DD')]
                            }
                            methods.memberChoose(res.Data.CaseManager)
                            params.fileList.value = res.Data.FileList && res.Data.FileList.map(e => {
                                return {
                                    url:e.url ? e.url : imageBaseUrl + e.FilePath.split('../..')[1],
                                    name: e.FileName,
                                    uid: e.uid,
                                    FileId: e.FileId
                                }
                            })

    

                        })

                    })
                    }

                    break;

                case 1:


                    Request({
                        url: "/performance/GetPlanDetail",
                        method: 'post',
                        params: {
                            FormId: id,
                            Step: +step + 1
                        }
                    }).then(res => {

                        if (res.Data.length != 0) {
                            params.groupList.value = res.Data.map(e => {

                                let s = e.MemberList.map(es => {
                                    return {
                                        prule: es.JobRole,
                                        pname: es.MemberName,
                                        ptel: es.Phone,
                                        pduty: es.JobTitle,
                                        MemberId: es.Id,
                                        pname: es.UserNo
                                    }
                                })
                                e.MemberList = s
                                return e

                            })
                        }
             
                       
                    })









                    break;

                case 2:
                    Request({
                        url: "/performance/getplanteamlist",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res => {

                        params.sgroupList.value = res.Data.map(e => {
                            return {
                                label: e.TeamName,
                                value: e.Id,
                                list: e.MemberList
                            }
                        })
                    })
                    Request({
                        url: "/performance/getplandepartments",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res1 => {
 
                        params.beCheckDeptList.value = res1.Data.map(e => {
                            return {
                                label: e.DepartmentName,
                                value: e.Id,
                            }
                        })


                        Request({
                            url: "/performance/GetPlanDetail",
                            method: 'post',
                            params: {
                                FormId: id,
                                Step: +step + 1
                            }
                        }).then(res => {
                            if (res.Data.length != 0) {
                                params.dateList.value = res.Data.map(e => {
                                    const regex = /\/Date\((\d+)\)\//;
                                    const match1 = e.StartTime.match(regex);
                                    const match2 = e.EndTime.match(regex);
                                    if (match1 && match2) {

                                        e.StartTime = dayjs(parseInt(match1[1], 10)).format('YYYY-MM-DD HH:mm:ss')
                                        e.EndTime = dayjs(parseInt(match2[1], 10)).format('YYYY-MM-DD HH:mm:ss')

                                        e.AllTime = [dayjs(e.StartTime, 'YYYY-MM-DD HH:mm:ss'), dayjs(e.EndTime, 'YYYY-MM-DD HH:mm:ss')]
                                    }
                                    e.gmember = e.TeamInfo.MemberList.map(es => `${es.MemberName}(${es.UserNo})`)
                                    return e
                                })
                            }
                        })















                    })
                    break;

                case 3:

                    Request({
                        url: "/performance/getplandepartments",
                        method: 'post',
                        params: {
                            FormId: params.cmainId.value
                        }
                    }).then(res1 => {
                        params.s4Form.value.dept = res1.Data.map(e => e.DepartmentName).toString()

                        Request({
                            url: "/performance/GetPlanDetail",
                            method: 'post',
                            params: {
                                FormId: id,
                                Step:+step+1
                            }
                        }).then(res => {
      
                            const { Title, Content } = res.Data
                            params.s4Form.value.Title = Title
                            params.s4Form.value.Content = Content
                               
                        })

                    })
                    break;




            }







     },

        onBack: () => {
            window.location.href ="/Performance/PerformancePlanPageList"
        }




    }
            //<a-button v-on:click="onSave" type="primary">保存</a-button>
                        //<a-button v-on:click="onSbumit" type="primary">提交</a-button>
    const template = {

        pdfPopModel: {
            template: `
           <a-modal v-model:open="pdfOpen" width = "80%" title = "PDF预览" v-on:ok="pdfOpen=false" >
<div style='height:700px'>
                <embed id="pdfviewscreen" :src="pdfurl" type="application/pdf" width="100%" style="height:100%;" />

</div>
  
            </a-modal >
`,
            setup() {
                return {
                    ...params,
                    ...methods,
                };
            }
        },

        bottomBtns: {
            template: `<div class="w-full bg-[#eeeeee] h-50  flex  items-center justify-end">
                    <a-space>
                        <a-button v-on:click="onBack">返回</a-button>
                    </a-space>
                </div>`,
            setup() {

                return {
                    ...params,
                    ...methods,
                };
            }

        }
    }
    return {
        ...params,
        ...methods,
        template
    }
}

export default Composition
